home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_04
/
saks
/
lns1b1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-09
|
649b
|
41 lines
----------
Listing 7 - member function definitions for lns using a pair of pointers
//
// lns1b.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::lns(unsigned n)
{
first = last = new node(n);
}
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
if (last->number != n)
last = last->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf("%4d ", p->number);
}